package demo;

import java.util.ArrayList;
import java.util.function.Predicate;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : EmployeeService
 * @Author : 54061
 * @Date: 2022/2/25 20:54
 */
public class EmployeeService {

    private ArrayList<Employee> all;

    public EmployeeService() {
        all = new ArrayList<Employee>();
        all.add(new Employee(1, "张三", '男', 33, 8000));
        all.add(new Employee(2, "翠花", '女', 23, 18000));
        all.add(new Employee(3, "无能", '男', 46, 8000));
        all.add(new Employee(4, "李四", '女', 23, 9000));
        all.add(new Employee(5, "老王", '男', 23, 15000));
        all.add(new Employee(6, "大嘴", '男', 23, 11000));
    }

    public ArrayList<Employee> get(Predicate<Employee> p) {
        ArrayList<Employee> list = new ArrayList<>();
        for (Employee employee : all) {
            if (p.test(employee)) {
                list.add(employee);
            }
        }
        return list;
    }
}
